package com.ddd.wandemo;

import com.base.BasePresenter;
import com.bean.BaseBean;
import com.bean.ToDoBean;
import com.net.ApiService;
import com.net.RetrofitServiceManager;
import com.net.RxResponseObserver;
import com.net.RxSchedulers;
import com.util.ToastUtil;

public class SplashPresenter extends BasePresenter<SplashContract.View> implements SplashContract.Presenter {
    @Override
    public void getTodoList(int status, int type, int page) {
        RetrofitServiceManager.getInstance().create(ApiService.class).getToDoList(status, type, page)
                .compose(RxSchedulers.<BaseBean<ToDoBean>>normalSchedulers())
                .compose(mView.<BaseBean<ToDoBean>>bindToLife())
                .subscribe(new RxResponseObserver<BaseBean<ToDoBean>>() {
                    @Override
                    public void onSuccess(BaseBean<ToDoBean> toDoBaseBean) {
                        if (toDoBaseBean.getData() != null) {
                            String title = toDoBaseBean.getData().getDatas().get(0).getTitle();
                        } else {
                            ToastUtil.showToast(toDoBaseBean.getErrorMsg());
                        }
                    }
                });
    }
}
